package com.mallcloud.mall.app.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.common.security.util.SecurityUtils;
import com.mallcloud.mall.product.api.entity.UserAddrModel;
import com.mallcloud.mall.product.service.UserAddrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "用户地址")
@RestController
@RequiredArgsConstructor
@RequestMapping("/app/userAddr")
public class AppUserAddrController {
    private final UserAddrService userAddrService;

    @ApiOperation("列表")
    @GetMapping("/list")
    public R<List<UserAddrModel>> save() {
        return R.ok(userAddrService.list(Wrappers.<UserAddrModel>lambdaQuery()
                .eq(UserAddrModel::getUserId, SecurityUtils.getUser().getId())
        ));
    }
}